<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 寄生组合式继承
    function Super(name, age) {
      this.name = name
      this.age = age
    }
    Super.prototype.getName = function () {
      console.log(this.name)
    }
    function Sub(name, age, sex) {
      Super.call(this, name, age)
      this.sex = sex
    }
    function object(o) {
      function F() { }
      F.prototype = o
      return new F()
    }
    function _prototype(Super, Sub) {
      let prototype = object(Super.prototype)
      prototype.constructor = Sub
      Sub.prototype = prototype
    }
    _prototype(Super, Sub)

    const sub = new Sub('朱晓荟', 12, '男')
    sub.getName()
  </script>
</body>

</html>
